package com.lemon.blog.web.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import com.lemon.common.log.annotation.Log;
import com.lemon.common.log.enums.BusinessType;
import com.lemon.common.security.annotation.RequiresPermissions;
import com.lemon.blog.web.domain.BiUserFollow;
import com.lemon.blog.web.service.IBiUserFollowService;
import com.lemon.common.core.web.controller.BaseController;
import com.lemon.common.core.web.domain.AjaxResult;
import com.lemon.common.core.utils.poi.ExcelUtil;
import com.lemon.common.core.web.page.TableDataInfo;

/**
 * 包名称：com.lemon.blog.web.controller
 * 类名称：BiUserFollowController
 * 类描述：用户关注表Controller
 * 创建人：@author lemon
 * 创建时间：2023-10-10
 */
@Api("用户关注表")
@RestController
@RequestMapping("/follow")
public class BiUserFollowController extends BaseController {

    @Autowired
    private IBiUserFollowService biUserFollowService;

    /**
     * 查询用户关注表列表
     * @Title: list
     * @Description: 查询用户关注表列表
     * @param biUserFollow 用户关注表
     * @return: TableDataInfo
     * @throws:
     * @author: lemon
     * @Date: 2023-10-10
     */
    @GetMapping("/list")
    public TableDataInfo list(BiUserFollow biUserFollow) {
        startPage();
        List<BiUserFollow> list = biUserFollowService.selectBiUserFollowList(biUserFollow);
        return getDataTable(list);
    }

    /**
     * 新增用户关注表
     * @Title: add
     * @Description: 新增用户关注表
     * @param biUserFollow 用户关注表
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-10-10
     */
    @Log(title = "用户关注表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BiUserFollow biUserFollow) {
        return toAjax(biUserFollowService.insert(biUserFollow));
    }

    /**
     * 删除用户关注表
     * @Title: remove
     * @Description: 删除用户关注表
     * @param ids 需要删除的用户关注表主键集合
     * @return: AjaxResult
     * @throws:
     * @author: lemon
     * @Date: 2023-10-10
     */
    @Log(title = "用户关注表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{followUserId}")
    public AjaxResult remove(@PathVariable Long followUserId) {
        return toAjax(biUserFollowService.deleteFollow(followUserId));
    }
}
